
export default {
  getExperAudit() {
    let searchItem = [
      {
        label: "实验名称",
        prop: "expName",
        input: true,
      },
      {
        label: "实验类型",
        prop: "expGroup",
        tag: true,
        list: [],
      },
      {
        label: "审核状态",
        prop: "checkState",
        tag: true,
        list: [
          {label:'待审批', id:1},
          {label:'通过', id:2},
          {label:'驳回', id:3},
        ],
      },
      {
        label: "申请人",
        prop: "person",
        input: true,
      },
    ];
    let buttonAll = {
      searchList: [
        {
          type: "search",
          text: "查询",
          icon: "el-icon-search",
          alwaysShow: true,
          types: "primary",
        },
        {
          type: "clear",
          text: "重置",
          icon: "el-icon-set-up",
          alwaysShow: true,
        },
        {
          type: "delete",
          text: "批量通过",
          icon: "el-icon-document-checked",
          alwaysShow: true,
          types: "primary",
        },
        {
          type: "import",
          text: "批量驳回",
          icon: "el-icon-document-delete",
          alwaysShow: true,
          types: "danger",  
        },
      ],
    };
    let titleList = [
      {
        label: '序号',
        prop: 'index',
        width:100,
        slot: true
      },
      {
        label: "实验名称",
        prop: "expName",
        width: 200,
      },
      {
        label: "实验类型",
        prop: "expGroup",
        width: 200,
        slot: true,
      },
      {
        label: "实验期限",
        prop: "range",
        width: 300,
        getData: row => {
          if (row.startTime && row.endTime) {
            return row.startTime + "至" + row.endTime;
          }
        },
      },
      {
        label: "申请人",
        prop: "person",
        width: 140,
        sort: true,
      },
      {
        label: "实验状态",
        prop: "state",
        width: 200,
        slot: true,
      },
      {
        label: "审核状态",
        prop: "checkState",
        slot: true
      },
      {
        label: "催批次数",
        prop: "urge",
        width: 150,
        slot: true,
      },
      {
        label: "操作",
        prop: "operate",
        width: 200,
        slot: true
      },
    ];
    let tableData = [];
    let moduleTitleList = [
      {
        label: '序号',
        prop: 'index',
        slot: true
      },
      {
        label: "模型名称",
        prop: "name",
        width: 120,
      },
      {
        label: "模型类型",
        prop: "type",
        width: 120,
      },
      {
        label: "规格",
        prop: "specification",
        width: 120,
      },
      {
        label: "余量/总量",
        prop: "total",
        slot: true,
        width: 120,
        getData: row => {
          if (row.unusedCount && row.totalCount) {
            return row.unusedCount + "/" + row.totalCount;
          }
        },
      },
      {
        label: "创建时间",
        prop: "createTime",
      },
      {
        label: "操作",
        prop: "count",
        slot: true
      },
    ];

    // 模型资源
    let modelResList = [
      {
        label: '编号',
        prop: 'index',
        width:100,
        slot: true
      },
      {
        label: "实验名称",
        prop: "expName",
        width: 200,
      },
      {
        label: "属性",
        prop: "expGroup",
        width: 200,
      },
      {
        label: "描述",
        prop: "expDes",
        width: 200,
      },
      {
        label: "每套申请数量",
        prop: "everyNum",
        width: 200,
      },
      {
        label: "申请总数",
        prop: "totalNum",
        width: 200,
      },
      {
        label: "资源余量",
        prop: "remainNum",
        width: 200,
      },
      {
        label: "阈值",
        prop: "threshold",
        slot: true
      }
    ]
    let hardTitleList = [
      {
        label: '序号',
        prop: 'index',
        slot: true
      },
      {
        label: "硬件名称",
        prop: "name",
        width: 120,
      },
      {
        label: "硬件资源",
        prop: "hardwareType",
        width: 120,
      },
      {
        label: "规格",
        prop: "specification",
        width: 120,
      },
      {
        label: "余量/总量",
        prop: "total",
        width: 120,
        slot: true,
        getData: row => {
          if (row.unusedCount && row.totalCount) {
            return row.unusedCount + "/" + row.totalCount;
          }
        },
      },
      {
        label: "创建时间",
        prop: "createTime",
      },
      {
        label: "操作",
        prop: "count",
        slot: true
      },
    ];
    let searchObj = {};

    searchItem.map((it) => {
      it.width = it.label.length == 2 ? '60px' : '100px'
      searchObj[it.prop] = "";
    });

    let searchData = { ...searchObj,  };

    function unique (arr) {
        return Array.from(new Set(arr))
    }

    return {
      searchItem,
      searchData,
      buttonAll,
      titleList,
      tableData,
      moduleTitleList,
      hardTitleList,
      unique,
      modelResList
    };
  },
};
